package com.egg.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
/**
 * @项目名称：egg   
 * @类名称：AuthorityInterceptor   
 * @类描述：权限拦截器   
 * @创建人：wangchenyang
 * @创建时间：2012-9-4 下午3:13:31   
 * @修改人：
 * @修改时间：   
 * @修改备注：   
 * @version
 */
public class AuthorityInterceptor extends MethodFilterInterceptor {
	private static final long serialVersionUID = 2855071154376065828L;

	protected String doIntercept(ActionInvocation invocation) throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session = request.getSession(true);
		String userId = String.valueOf(session.getAttribute("userId"));
		if (userId != null && !"".equals(userId)&&!"null".equals(userId)) {
			return invocation.invoke();
		}
		return Action.LOGIN;
	}

}
